<%@ Page Language="vb" AutoEventWireup="false" Codebehind="CreditNotes.aspx.vb" Inherits="MIMS_WRS.Web.CreditNotes" %>
<%@ Register TagPrefix="uc1" TagName="HelpCtrl" Src="../Controls/HelpCtrl.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Header" Src="../Controls/Header.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Footer" Src="../Controls/Footer.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>CreditNotes</title>
		<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<script language="javascript" src="../Js/popcalendar.js"></script>
		<script language="javascript" src="../Js/common.js"></script>
		<LINK href="../style.css" type="text/css" rel="stylesheet">
		<script language="JavaScript" src="../js/function.js" type="text/JavaScript"></script>
		<script language="javascript">
		
		var supplierCodeLKID = <%= MIMS_WRS.Business.Common.GetSupplierCodeLKID %>;
		
		function OpenLKList(obj,  textReturn, idReturn, title, w, h, id, valueno) {
		
			var pos = calcBelowPosition(obj, w);			
			var reval;			
			var url=escape('LookupDataListDialog.aspx?id='+id+'&t='+valueno);
			reval = window.showModalDialog('../Dialogs/ShowDialog.aspx?title='+escape(title)+'&src='+url,"","dialogHeight: " + h + "px; dialogWidth: " + w + "px; dialogTop: " + pos.top + "px; dialogLeft: " + pos.left + "px; edge: Raised; center: Yes; help: No; resizable: No; status: No;")
			
			if (reval != null) {
				textReturn.value = reval.Text;
				idReturn.value = reval.Value;
				return true;
			}
			return false
		}
		
		function OpenSupplierCodeList(obj,  textReturn, idReturn, title, w, h, id, valueno) {
			var pos = calcBelowPosition(obj,1,w,h);			
			var wi = 550;
			var he = 350;
			var lpos=(screen.width - wi)/2
			var tpos=(screen.height - he)/2		

			var reval;			
			//var url=escape('LookupDataListDialog.aspx?id='+id+'&t='+valueno);
			var url = escape('popup_supplier.htm');
			reval = window.showModalDialog('../Dialogs/ShowDialog.aspx?title='+escape(title)+'&src='+url,"","dialogHeight: " + he + "px; dialogWidth: " + wi + "px; dialogTop: " + tpos + "px; dialogLeft: " + lpos + "px; edge: Raised; center: Yes; help: No; resizable: No; status: No;")
			
			if (reval != null) {
				textReturn.value = reval.Text;
				idReturn.value = reval.Value;
				return true;
			}
			return false
		}
		
		function AddLK(obj, textReturn, idReturn, title, w, h, id, valueno) {
			var pos = calcBelowPosition(obj, w);
			var lpos=(screen.width - w)/2
			var tpos=(screen.height - h)/2		

			var reval;
			var url = escape('LookupDataInputDialog.aspx?id='+id);
			reval = window.showModalDialog('../Dialogs/ShowDialog.aspx?title='+escape(title)+'&src='+url,"","dialogHeight: " + h + "px; dialogWidth: " + w + "px; dialogTop: " + tpos + "px; dialogLeft: " + lpos + "px; edge: Raised; center: Yes; help: No; resizable: No; status: No;")
			if (reval != null) {
				switch (valueno) {
					case 1:
						textReturn.value = reval.Value1;
						break;
					case 2:
						textReturn.value = reval.Value2;
						break;
					case 3:
						textReturn.value = reval.Value3;
						break;
				}
				idReturn.value = reval.ID;			
				return true;
			}
			return false
		}
		
		function validateValue()
		{					
			var objValue = window.document.getElementById('txtValue');
			var valValue = objValue.value;
			
			var OK;
			if(val.Indexof('.') != -1)
			{
				var valPart1 = val.substr(val.Indexof('.'))
				if(isNaN(valPart1))
				{
					OK = false;
				}
				else
				{
					var valPart2 = val.substring(val.Indexof('.')+1,val.length);
					if(isNaN(valPart2))
						OK = false;
					else
						OK = true;
				}
			}
			else
			{
				if(!isNaN(val))
					OK = true;
				else
					OK= false;
			}
			alert(OK);
			return OK;			
		}
		
		function btnSave_onclick() 
		{
			/*
			var objNumber = window.document.getElementById('txtNumber');
			var valNumber = objNumber.value;
				
			if(valNumber.length != 10)
			{
				alert('Number must be 10 digits long');
				objNumber.focus();
				return false;
			}						
			if (isNaN(valNumber))
			{	
				alert('Number must is Number format');
				objNumber.focus();
				return false;						
			}			
			else
			{
				if(valNumber < 0 )
				{
					alert('Number must be a positive number');
					objNumber.focus();
					return false;						
				}
			}
			*/
			var objValue = window.document.getElementById('txtValue');
			var valValue = objValue.value;
			if (isNaN(valValue))
			{	
				alert('Value must is Number format');
				objValue.focus();
				return false;						
			}	
			else
			{
				if(valValue < 0 )
				{
					alert('Value must be a positive number');
					objValue.value = 0
					objValue.focus();
					return false;						
				}
			}		
			return true;
		}		
			
		function body_onload() {
			
			if (window.document.getElementById('btnSave'))
				window.document.getElementById('btnSave').onclick = btnSave_onclick;				
		}
		</script>
	</HEAD>
	<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('../images/b_weeklyreporto.gif','../images/b_historyreporto.gif','../images/b_usero.gif')">
		<form id="Form1" method="post" runat="server">
			<table cellSpacing="0" cellPadding="0" width="100%" border="0">
				<uc1:Header id="Header1" runat="server"></uc1:Header>
				<!-- Submenu: start -->
				<TBODY>
					<tr>
						<td>
							<table id="Table1" cellSpacing="0" cellPadding="0" width="100%" border="0">
								<tr>
									<td class="bgsubmenu" align="center" height="30"><div class="nlink">
											<table cellSpacing="0" cellPadding="0" width="96%" border="0">
												<tr>
													<td class="txtcolor2">
														<p><span class="txtsmall"><strong>You are here:</strong></span> <span class="txtcolor2">
																<A href="CustomerList.aspx">Customer list</A> / <a href="CreditNotesList.aspx?UserId=<%=CustomerId%>">
																	Credit notes list</a> /
																<asp:Label id="lblCurrentPage" runat="server">Create new credit notes</asp:Label></span>
														</p>
													</td>
													<td align="right" class="txtcolor2"><strong><asp:HyperLink id="hrefCNCreateNew" runat="server" NavigateUrl="CreditNotes.aspx">Create 
															New Credit Notes</asp:HyperLink></strong></td>
													<td class="txtcolor2" noWrap align="right" width="70"><span class="plink"><A href="javascript:history.back()"><IMG height="16" hspace="2" src="../images/b_back.gif" width="57" vspace="0" border="0"></A></span></td>
												</tr>
											</table>
										</div>
									</td>
								</tr>
								<tr>
									<td class="bglinetop1" height="1"><IMG height="1" src="../images/1pxl.gif" width="1"></td>
								</tr>
								<!-- Submenu: end -->
								<!-- DataTable : start -->
								<tr>
									<td align="center" valign="top" class="bgwhite"><table width="90%" border="0" cellspacing="0" cellpadding="0">
											<tr>
												<td height="35" align="center"><table width="100%" border="0" cellpadding="0" cellspacing="0">
														<tr>
															<td width="56%" height="25" valign="bottom">
																<span class="title"><strong><span class="title"><strong>
																				<asp:Label id="lblTitle" runat="server"></asp:Label></strong></span></strong></span></td>
															<td width="44%" align="right" valign="bottom"><span class="plink"><strong><span class="txtsmall"><a href="#">
																				<uc1:HelpCtrl id="HelpCtrl1" runat="server"></uc1:HelpCtrl></a></span></strong></span></td>
														</tr>
													</table>
													<table width="100%" height="25" border="0" cellpadding="0" cellspacing="0" id="msgTable"
														style="DISPLAY:none">
														<tr>
															<td align="center" class="txthighlight"><asp:Label id="lblErr" runat="server" Font-Bold="True" ForeColor="Red"></asp:Label></td>
														</tr>
													</table>
												</td>
											</tr>
											<tr>
												<td align="center" valign="top">
													<table width="100%" border="0" cellspacing="0" cellpadding="0">
														<tr>
															<td align="center" valign="top">
																<table width="100%" border="0" cellpadding="2" cellspacing="2" class="border1">
																	<tr>
																		<td align="center" bgcolor="#f9f9f9">
																			<TABLE width="100%" border="0" cellPadding="3" cellSpacing="0">
																				<TR align="center" class="bgmenu">
																					<TD colspan="3">&nbsp;</TD>
																				</TR>
																				<TR class="txtnormal">
																					<TD width="41%" align="right">Number:</TD>
																					<TD width="1%" align="center">&nbsp;</TD>
																					<TD width="58%">
																						<asp:TextBox id="txtNumber" runat="server" cssclass="txtsmall" MaxLength="10"></asp:TextBox>
																						<strong><span class="txthighlight"><strong>*</strong></span></strong>
																						<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ErrorMessage="Required" ControlToValidate="txtNumber"
																							CssClass="txthighlight" Display="Dynamic"></asp:RequiredFieldValidator>
																						<asp:RegularExpressionValidator id="regvNumber" runat="server" CssClass="txthighlight" ControlToValidate="txtNumber"
																							ErrorMessage="must be 1-10 alphanumeric characters" Display="Dynamic" ValidationExpression="[a-zA-Z0-9]{1,10}"></asp:RegularExpressionValidator></SPAN>
																					</TD>
																				</TR>
																				<TR class="txtnormal">
																					<TD align="right">Date</TD>
																					<TD align="center">&nbsp;</TD>
																					<TD><table border="0" cellspacing="0" cellpadding="0">
																							<tr>
																								<td><asp:TextBox id="txtDate" runat="server" CssClass="txtsmall" ReadOnly="True"></asp:TextBox></td>
																								<td><A onclick="popUpCalendar(this, window.document.getElementById('txtDate'), '<%= MIMS_WRS.Business.Common.GetDateFormat %>')" href="javascript:doNothing()" >
																										<IMG id="btnDate" height="20" hspace="1" src="../images/b_date.gif" width="20" border="0"></A></td>
																								<td><span class="txthighlight"><strong><span class="txthighlight"><strong> *</strong></span>
																											<asp:RequiredFieldValidator id="RequiredFieldValidator4" runat="server" CssClass="txthighlight" ControlToValidate="txtDate"
																												ErrorMessage="Required"></asp:RequiredFieldValidator></strong></span>
																								</td>
																							</tr>
																						</table>
																					</TD>
																				</TR>
																				<TR class="txtnormal">
																					<TD align="right">
																						Supplier for each Credit Notes number:</TD>
																					<TD align="center">&nbsp;</TD>
																					<TD>
																						<table border="0" cellspacing="0" cellpadding="0">
																							<tr>
																								<td><asp:textbox id="txtSupplierCode" runat="server" CssClass="txtsmall" Width="136px" MaxLength="3"
																										ReadOnly="True"></asp:textbox></td>
																								<td><A onclick="OpenSupplierCodeList(this, window.document.getElementById('txtSupplierCode'), window.document.getElementById('hidSupplierID'), 'Select a supplier code', 420, 180, supplierCodeLKID, 1)"
																										href="javascript:doNothing()"><IMG height="20" hspace="1" src="../images/b_browse.gif" width="22" border="0"><A onclick="AddLK(this, window.document.getElementById('txtSupplierCode'),  window.document.getElementById('hidSupplierID'),'Enter a new supplier', 420, 200, supplierCodeLKID, 1)"
																											href="javascript:doNothing()"><IMG height="20" hspace="4" src="../images/b_new.gif" width="72" border="0"></A></A></td>
																								<td><FONT class="txthighlight">* </FONT>
																									<asp:requiredfieldvalidator id="reqvSupplierCode" runat="server" CssClass="txthighlight" ErrorMessage="Missing Supplier Code"
																										ControlToValidate="txtSupplierCode" Display="Dynamic">Required</asp:requiredfieldvalidator><INPUT class="txtsmall" id="hidSupplierID" type="hidden" name="hidSupplierID" runat="server"><FONT color="red"></FONT>
																								</td>
																							</tr>
																						</table>
																					</TD>
																				</TR>
																				<TR class="txtnormal">
																					<TD align="right" valign="top">Description:</TD>
																					<TD align="center">&nbsp;</TD>
																					<TD>
																						<asp:TextBox id="txtDescription" runat="server" CssClass="txtsmall" Width="240px" MaxLength="2000"
																							TextMode="MultiLine" Height="64px"></asp:TextBox>
																						<span class="txthighlight"><strong>* </strong></span>
																						<asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" ErrorMessage="Required" ControlToValidate="txtDescription"
																							CssClass="txthighlight"></asp:RequiredFieldValidator>
																						<span class="txthighlight"><strong></strong></span>
																					</TD>
																				</TR>
																				<TR class="txtnormal">
																					<TD align="right">Value:</TD>
																					<TD align="center">&nbsp;</TD>
																					<TD><strong>
																							<asp:TextBox id="txtValue" runat="server" CssClass="txtsmall" Width="128px" MaxLength="14"></asp:TextBox>
																							<span class="txtnormal"><strong>USD</strong></span><span class="txthighlight"><strong> *</strong></span></strong>
																						<asp:RequiredFieldValidator id="RequiredFieldValidator3" runat="server" ErrorMessage="Required" ControlToValidate="txtValue"
																							CssClass="txthighlight"></asp:RequiredFieldValidator>
																					</TD>
																				</TR>
																			</TABLE>
																			<TABLE width="100%" border="0" cellPadding="3" cellSpacing="0">
																				<TR class="txtnormal">
																					<TD height="30" align="right" valign="bottom" class="bgsubmenu">All fields with red 
																						(<span class="txthighlight">*</span>) mark are required field.</TD>
																				</TR>
																				<TR class="txtnormal">
																					<TD height="40" align="center" class="txtsmall">
																						<asp:Button id="btnSave" runat="server" Text="Save" CssClass="button"></asp:Button>&nbsp;
																						<input name="btnReset" type="reset" class="button" value="Reset">
																						<script event="onclick" for="btnSave">													
																if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate();																	
																return btnSave_onclick();																																	
																						</script>
																						<asp:Button id="btnCancel" runat="server" Text="Cancel" CssClass="button" CausesValidation="False"></asp:Button>
																						<script event="onclick" for="btnCancel">
																if(!confirm('Are you sure you want to cancel?')) 
																	return false;
																						</script>
																					</TD>
																				</TR>
																			</TABLE>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
											<tr>
												<td align="center" valign="top">&nbsp;</td>
											</tr>
											<tr>
												<td align="center" valign="top">&nbsp;</td>
											</tr>
										</table>
									</td>
								</tr>
								<uc1:Footer id="Footer1" runat="server"></uc1:Footer>
							</table>
		</form>
		</TD></TR></TBODY></TABLE>
	</body>
</HTML>
